package com.yanqu.road.server.cmd.activity.unionwar;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.unionwar.UnionWarActivityServerProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.unionwar.UnionWar;
import com.yanqu.road.server.manger.activity.unionwar.UnionWarActivityMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.string.StringUtils;

@Cmd(code = GameProtocol.S_UNION_WAR_PREPARE_NO_DISPATCH_MEMBER, desc = "未派遣成员")
public class UnionWarActivtyGetNoDispatchMemberCmd extends AbstractCommand {

    private int activityId;
    private int phase;
    private int session;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        UnionWarActivityServerProto.UnionWarGetNoDispatchMemberReqMsg reqMsg = UnionWarActivityServerProto.UnionWarGetNoDispatchMemberReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        phase = reqMsg.getPhase();
        session = reqMsg.getSession();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ActivityInfo activityInfo = UnionWarActivityMgr.getOpenActivityInfo(activityId);
        if(activityInfo == null){
            ret = GameErrorCode.E_ACTIVITY_NO_FOUND;
            return;
        }
        String unionUid = UnionWar.getUserUnionUid(activityId, player.getUserInfo());
        if(StringUtils.isNullOrEmpty(unionUid)){
            ret = GameErrorCode.E_UNION_NO_JOIN_UNION;
            return;
        }

        UnionWarActivityServerProto.UnionWarGetNoDispatchMemberReqMsg.Builder crossReq = UnionWarActivityServerProto.UnionWarGetNoDispatchMemberReqMsg.newBuilder();
        crossReq.setActivityId(activityId);
        crossReq.setPhase(phase);
        crossReq.setSession(session);
        player.sendUnionActivityGroupPacket(Protocol.C_UNION_WAR_PREPARE_NO_DISPATCH_MEMBER, crossReq, activityId);
        //ret = UnionPhaseWarMgr.getNoDispatchMember(player, activityId, unionUid, phase, session);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
